package WaiBao;

import sun.security.provider.Sun;

import java.util.Arrays;

public class YangJing {
    public static void main(String[] args) {
        String[] name = {"李道华(班长)", "李思远(副班长)", "李大海(组织委员)", "王超(体育委员)", "张李伟", "李忠强", "王大胖", "李浩", "王志刚", "杜域名", "赵配强", "裴职员",
                "鲍怀安", "李迅", "刘合资", "玮正", "戴天理", "那英", "凌捧腹", "林自科", "李朗", "白敬停", "黄训", "马自愿", "李浪", "马致远", "雷敬", "王磊",
                "王源", "杨静(学生)"};//考生本人:杨静(学生)
        int[] age = {19, 20, 19, 18, 19, 18, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 21, 19};
        double[] t1 = {78, 82, 84, 90, 88, 69, 78, 89, 80, 90, 90, 67, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 74, 81, 91};
        double[] t2 = {79, 85, 79, 66, 68, 67, 88, 99, 90, 90, 90, 67, 66, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 84, 74, 64, 94, 93};
        double[] t3 = {88, 86, 80, 95, 79, 99, 68, 89, 80, 60, 93, 87, 85, 65, 65, 68, 89, 69, 96, 93, 92, 81, 95, 85, 76, 84, 73, 71, 88, 94};

        double Sum1;//代表每个学生的总分
        double average;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            Sum1 = t1[i] + t2[i] +t3[i];
//            average = (Sum1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + Sum1);
//            System.out.println(name[i] + "的平均分为:" +average);
//        }
//
//
        double Result = 0, Average = 0;
        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            Result = t1[i] + t2[i] + t3[i];
//            average = (Result * 1.0) / 3;
//            Array[i] = average;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double tep = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }
//
//
        double g1 = 0, g2 = 0, g3 = 0;//计算每门课的平均分
        double f1 = 0, f2 = 0, f3 = 0;//计算每门课标准差
        double m1 = 0, m2 = 0, m3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < t1.length; i++) {
            sum2+=t1[i];
        }
        g1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+g1);
        double Sum = 0;
        for (int i = 0; i < t2.length; i++) {
            Sum+=t2[i];
        }
        g2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+g2);
        double sum = 0;
        for (int i = 0; i <t3.length; i++) {
            sum+=t3[i];
        }
        g3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+g3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < t1.length; i++) {
            c1+= (t1[i] - g1)*(t1[i] - g1);
        }
        f1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+f1);

        for (int i = 0; i < t2.length; i++) {
            c2+= (t2[i] - g2)*(t2[i] - g2);
        }
        f2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+f2);

        for (int i = 0; i < t3.length; i++) {
            c3+= (t3[i] - g3)*(t3[i] - g3);
        }
        f3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+f3);
//
//        Arrays.sort(t1);
//        Arrays.sort(t2);
//        Arrays.sort(t3);
//        m1 =( t1[15]+t1[16])*1.0/2;
//        m2 =( t2[15]+t2[16])*1.0/2;
//        m3 =( t3[15]+t3[16])*1.0/2;
//        System.out.println("分析化学的中位数为:"+m1);
//        System.out.println("线性代数的中位数为:"+m2);
//        System.out.println("有机化学的中位数为:"+m3);
    }
}
